package com.itheima.exce;

import java.text.ParseException;

public class ExceptionDemo1 {
    public static void main(String[] args) {
//        int[] arr = {1, 2, 3, 4, 5};
        int[] arr = null;
        try {
            printArr(arr);
        } catch (NullPointerException e) {
            System.out.println("参数不能为null");
        }

        System.out.println("ABCDE");
    }

    private static void printArr(int[] arr) {
        if (arr == null) {
            //System.out.println("参数不能为null");
            throw new NullPointerException();
        } else {
            for (int i = 0; i < arr.length; i++) {
                System.out.println(arr[i]);
            }
        }
    }
}

